package com.feihao.demo01DateJDK8;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;

public class DemoLocaDateTime {
    public static void main(String[] args) {
        //方法：
        LocalDateTime localDateTime = LocalDateTime.now();
        int dayOfMonth = localDateTime.getDayOfMonth();
        System.out.println(dayOfMonth);

        DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
        System.out.println(dayOfWeek);


        LocalDateTime localDateTime1 = localDateTime.plusYears(1);
        System.out.println(localDateTime1);

        //格式化器：
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        //格式化：
        String format = dtf.format(localDateTime1);
        System.out.println(format);

        //解析：
        String dataString  = "2020-02-02 13:14:20";
        LocalDate parse = LocalDate.parse(dataString, dtf);
        System.out.println(parse);
    }
}
